package com.voxel.sense.infomsg.module.trace.staff;

import com.example.com.common.factory.data.DataSource;
import com.example.com.common.utils.ToastUtil;
import com.voxel.sense.infomsg.base.RecyclerViewPresenter;

import java.util.List;

import cyy.example.com.facotry.Factory;
import cyy.example.com.facotry.model.api.response.ClockInUserListEntity;
import cyy.example.com.facotry.net.helper.NetHelper;

/**
 * Created by ChenYiYao on 2018/5/14.
 */

public class StaffClockInListPresenter extends RecyclerViewPresenter<StaffClockInListContract.View>
        implements StaffClockInListContract.Presenter, DataSource.Callback<ClockInUserListEntity> {


    public StaffClockInListPresenter(StaffClockInListContract.View view) {
        super(view);
    }

    @Override
    protected void loadData() {
        NetHelper.getHaveTraceUser(this);
    }

    @Override
    protected void loadMoreData() {

    }

    @Override
    public void doLoadData() {
        mView.showLoading("");
        startRefreshData();
    }

    @Override
    public void doLoadMoreData() {

    }


    @Override
    public void onDataLoaded(ClockInUserListEntity data, int reqId) {
        if (mView == null)
            return;
        mView.dimissLoading();
        if (data != null && data.isSuccess()) {
            List<ClockInUserListEntity.BodyBean> body = data.getBody();
//            if (body.size()<1){
//                mView.showEmptyView(data.msg);
//            }
            loadDataComplete(body);
        }else {
            LoadDataFailure();
        }
    }

    @Override
    public void onDataNotAvailable(String strRes, int reqId) {
        if (mView == null)
            return;
        mView.dimissLoading();
        LoadDataFailure();
//        mView.showEmptyView(Factory.app().getString(R.string.network_unavailable));
        ToastUtil.showToastLong(Factory.app(), strRes);

    }

}
